@echo off
chcp 65001
set "scriptDir=%~dp0"
cd /d "%scriptDir%"
powershell -Command "Write-Host '■ STL库编译' -ForegroundColor Green"
cd stl
if exist build (
    powershell -Command "Write-Host '删除旧build目录...' -ForegroundColor Yellow"
    rd /s /q build
)
mkdir build && cd build
cmake -G "MinGW Makefiles" ..  && mingw32-make
powershell -Command "Write-Host '■ 词法分析器编译' -ForegroundColor Green"
cd ../../lexanalyze
if exist build (
    powershell -Command "Write-Host '删除旧build目录...' -ForegroundColor Yellow"
    rd /s /q build
)
mkdir build && cd build
cmake -G "MinGW Makefiles" ..  && mingw32-make
powershell -Command "Write-Host '■ 语法分析器编译' -ForegroundColor Green"
cd ../../grammar
if exist build (
    powershell -Command "Write-Host '删除旧build目录...' -ForegroundColor Yellow"
    rd /s /q build
)
mkdir build && cd build
cmake -G "MinGW Makefiles" ..  && mingw32-make
powershell -Command "Write-Host '■ 工具编译' -ForegroundColor Green"
cd ../LL1/tools
if exist build (
    powershell -Command "Write-Host '删除旧build目录...' -ForegroundColor Yellow"
    rd /s /q build
)
mkdir build && cd build
cmake -G "MinGW Makefiles" ..  && mingw32-make
pause